package com.wswy.wyjk.ui.main

import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MutableLiveData
import com.wswy.wyjk.model.vo.CountPractice
import com.wswy.wyjk.ui.BasePracticeViewModel
import com.wswy.wyjk.utils.reSend
import timber.log.Timber

class SubjectHomeViewModel : BasePracticeViewModel() {


    private val countLiveData = MutableLiveData<CountPractice>().apply {

        postValue(CountPractice())

    }

    override fun onDataLoaderComplete() {
        super.onDataLoaderComplete()
        loadCount()
    }

    fun loadCount(){

        val st = System.currentTimeMillis()

        countLiveData.postValue(CountPractice().apply {
            count = dataLoader?.countPractice()?:0
            completed = dataLoader?.countComplete()?:0
        })

        Timber.e("count time ${System.currentTimeMillis() - st}")
    }

    fun getCountLiveData():LiveData<CountPractice> = countLiveData

}